home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgLangD.iso / BORLAND TURBO / OWLSRC.PAK / GROUPBOX.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-06  |  3.1 KB  |  127 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows
  3. // Copyright (c) 1991, 1997 by Borland International, All Rights Reserved
  4. //
  5. //$Revision:   10.5  $
  6. //
  7. // Implementation of class TGroupBox.  This defines the basic behavior for all
  8. // group boxes.
  9. //----------------------------------------------------------------------------
  10. #pragma hdrignore SECTION
  11. #include <owl/pch.h>
  12. #if !defined(OWL_GROUPBOX_H)
  13. # include <owl/groupbox.h>
  14. #endif
  15. #if !defined(OWL_APPLICAT_H)
  16. # include <owl/applicat.h>
  17. #endif
  18.  
  19. #if defined(BI_COMP_BORLANDC)
  20. # include <bwcc.h>
  21. #endif
  22.  
  23. OWL_DIAGINFO;
  24.  
  25. #if !defined(SECTION) || SECTION == 1
  26.  
  27. //
  28. // constructor for a TGroupBox object
  29. //
  30. // by default, the parent window is notified when the state of the group box's
  31. // selection boxes has changed
  32. //
  33. TGroupBox::TGroupBox(TWindow*        parent,
  34.                      int             id,
  35.                      const char far* text,
  36.                      int x, int y, int w, int h,
  37.                      TModule*        module)
  38. :
  39.   TControl(parent, id, text, x, y, w, h, module)
  40. {
  41.   NotifyParent = true;
  42.   Attr.Style = (Attr.Style | BS_GROUPBOX) & ~WS_TABSTOP;
  43. }
  44.  
  45. //
  46. // Return name of predefined BWCC shade or Windows groupbox class
  47. //
  48. char far*
  49. TGroupBox::GetClassName()
  50. {
  51. #if defined(BI_COMP_BORLANDC)
  52.   if (GetApplication()->BWCCEnabled())
  53.     return SHADE_CLASS;
  54.   else
  55. #endif
  56.     return "BUTTON";
  57. }
  58.  
  59. //
  60. // constructor for a TGroupBox to be associated with a MS-Windows interface
  61. // element created by MS-Windows from a resource definition
  62. //
  63. // by default, the parent window is notified when the state of the group box's
  64. // selection boxes has changed
  65. //
  66. // disables transfer of state data for the TGroupBox
  67. //
  68. TGroupBox::TGroupBox(TWindow*   parent,
  69.                      int        resourceId,
  70.                      TModule*   module)
  71. :
  72.   TControl(parent, resourceId, module)
  73. {
  74.   NotifyParent = true;
  75.   DisableTransfer();
  76. }
  77.  
  78. //
  79. // notifies parent that the selection in the associated groupbox has
  80. // changed
  81. //
  82. // this method is called by TCheckBoxes grouped in the groupbox when
  83. // their state changes
  84. //
  85. void
  86. TGroupBox::SelectionChanged(int controlId)
  87. {
  88.   if (NotifyParent)
  89. #if defined(BI_PLAT_WIN32)
  90.     Parent->PostMessage(WM_COMMAND, MkParam1(Attr.Id, controlId),
  91.                         TParam2(GetHandle()));
  92. #else
  93.     Parent->PostMessage(WM_COMMAND, Attr.Id, MkParam2(uint16(GetHandle()), controlId));
  94. #endif
  95. }
  96.  
  97. #endif
  98. #if !defined(SECTION) || SECTION == 2
  99.  
  100. IMPLEMENT_STREAMABLE1(TGroupBox, TControl);
  101.  
  102. #if !defined(BI_NO_OBJ_STREAMING)
  103.  
  104. //
  105. // reads an instance of TGroupBox from the passed ipstream
  106. //
  107. void*
  108. TGroupBox::Streamer::Read(ipstream& is, uint32 /*version*/) const
  109. {
  110.   ReadBaseObject((TControl*)GetObject(), is);
  111.   is >> GetObject()->NotifyParent;
  112.   return GetObject();
  113. }
  114.  
  115. //
  116. // writes the TGroupBox to the passed opstream
  117. //
  118. void
  119. TGroupBox::Streamer::Write(opstream& os) const
  120. {
  121.   WriteBaseObject((TControl*)GetObject(), os);
  122.   os << GetObject()->NotifyParent;
  123. }
  124. #endif  // if !defined(BI_NO_OBJ_STREAMING)
  125.  
  126. #endif
  127.